from datetime import datetime, date
from json import JSONEncoder


class CustomJson(JSONEncoder):
    """自定义json解析规则"""
    def default(self, obj):
        if isinstance(obj, (datetime, date)):
            return int(obj.timestamp() * 1000)  # 日期转时间戳
        return super().default(obj)
